<html>
<head><meta charset="utf-8"><title>postfix macros · t-lang · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/index.html">t-lang</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/postfix.20macros.html">postfix macros</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="215980375"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/postfix%20macros/near/215980375" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/postfix.20macros.html#215980375">(Nov 08 2020 at 00:17)</a>:</h4>
<p>It looks like there's some renewed interest in postfix macros (cc <span class="user-mention" data-user-id="120096">@est31</span>). I just rewrote <a href="https://github.com/rust-lang/rfcs/pull/2442">RFC 2442</a>, to account for changes in Rust (specifically, <code>await!(expr)</code> becoming <code>expr.await</code>).</p>



<a name="215980423"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/postfix%20macros/near/215980423" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/postfix.20macros.html#215980423">(Nov 08 2020 at 00:18)</a>:</h4>
<p>I've carefully removed anything in RFC 2442 that was using await syntax as potential motivation, since we've now solved that problem.</p>



<a name="215980429"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/postfix%20macros/near/215980429" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/postfix.20macros.html#215980429">(Nov 08 2020 at 00:18)</a>:</h4>
<p>Instead, I'm treating it as additional motivation for the desirability of postfix syntax.</p>



<a name="216024159"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/postfix%20macros/near/216024159" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/postfix.20macros.html#216024159">(Nov 08 2020 at 20:36)</a>:</h4>
<p>Does the <code>$self</code> in that RFC conflict with the discussion about allowing <code>$self::foo::Bar</code> in paths?</p>



<a name="216029147"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/postfix%20macros/near/216029147" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/postfix.20macros.html#216029147">(Nov 08 2020 at 22:42)</a>:</h4>
<p><span class="user-mention" data-user-id="125270">@scottmcm</span> Interesting point!</p>



<a name="216029947"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/postfix%20macros/near/216029947" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/postfix.20macros.html#216029947">(Nov 08 2020 at 23:01)</a>:</h4>
<p><span class="user-mention" data-user-id="125270">@scottmcm</span> It hadn't occurred to me until just now that the syntax of <code>$crate</code> and the syntax of <code>$somevar</code> overlap.</p>



<a name="216030025"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/postfix%20macros/near/216030025" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/postfix.20macros.html#216030025">(Nov 08 2020 at 23:03)</a>:</h4>
<p>But sure enough, you can't use <code>$crate</code> as the name of a macro argument.</p>



<a name="216030034"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/postfix%20macros/near/216030034" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/postfix.20macros.html#216030034">(Nov 08 2020 at 23:03)</a>:</h4>
<p>And if we allow <code>$self</code> (and perhaps <code>$super</code>) by analogy with <code>$crate</code>, that <em>would</em> generate a conflict.</p>



<a name="216030097"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/postfix%20macros/near/216030097" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/postfix.20macros.html#216030097">(Nov 08 2020 at 23:04)</a>:</h4>
<p>Interestingly, you <em>can</em> name a macro argument <code>$self</code> or <code>$super</code> today.</p>



<a name="216030116"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/postfix%20macros/near/216030116" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/postfix.20macros.html#216030116">(Nov 08 2020 at 23:05)</a>:</h4>
<p>Which means introducing those as proposed by <a href="https://github.com/rust-lang/rfcs/pull/2968">RFC 2968</a> would be a breaking change.</p>



<a name="216030823"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/postfix%20macros/near/216030823" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/postfix.20macros.html#216030823">(Nov 08 2020 at 23:21)</a>:</h4>
<p><span class="user-mention" data-user-id="125270">@scottmcm</span> Writing up a summary for the postfix macros thread. Suggestions welcome.</p>



<a name="216031059"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/postfix%20macros/near/216031059" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/postfix.20macros.html#216031059">(Nov 08 2020 at 23:26)</a>:</h4>
<p>Oh, interesting.  I'm surprised keywords aren't just blanket blocked in macro identifier names.</p>



<a name="216031247"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/postfix%20macros/near/216031247" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/postfix.20macros.html#216031247">(Nov 08 2020 at 23:31)</a>:</h4>
<p>They don't seem to be.</p>



<a name="216031270"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/postfix%20macros/near/216031270" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/postfix.20macros.html#216031270">(Nov 08 2020 at 23:31)</a>:</h4>
<p>On a different note, someone in the RFC thread made a good suggestion about syntax:</p>



<a name="216031333"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/postfix%20macros/near/216031333" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/postfix.20macros.html#216031333">(Nov 08 2020 at 23:32)</a>:</h4>
<p>Rather than <code>($self:self, $other:tt, $arguments:expr) =&gt; ...</code>, with a comma that doesn't correspond to any actual syntax used at invocation, it would make sense to pull <code>$self</code> (or whatever we call it) out of the parens:</p>



<a name="216031366"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/postfix%20macros/near/216031366" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/postfix.20macros.html#216031366">(Nov 08 2020 at 23:33)</a>:</h4>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="n">macro_rules</span><span class="o">!</span><span class="w"> </span><span class="n">postfix</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="cp">$self</span><span class="p">.(</span><span class="cp">$arg1</span>:<span class="nc">tt</span><span class="p">,</span><span class="w"> </span><span class="cp">$arg2</span>:<span class="nc">expr</span><span class="p">)</span><span class="w"> </span><span class="o">=&gt;</span><span class="w"> </span><span class="o">..</span><span class="p">.</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>



<a name="216031376"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/postfix%20macros/near/216031376" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/postfix.20macros.html#216031376">(Nov 08 2020 at 23:33)</a>:</h4>
<p>Does that seem like it'd cause any potential parsing issues, when parsing the macro definition itself?</p>



<a name="216031381"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/postfix%20macros/near/216031381" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/postfix.20macros.html#216031381">(Nov 08 2020 at 23:33)</a>:</h4>
<p>If not, I think that's rather appealing.</p>



<a name="216031469"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/postfix%20macros/near/216031469" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/postfix.20macros.html#216031469">(Nov 08 2020 at 23:35)</a>:</h4>
<p><span class="user-mention silent" data-user-id="125270">scottmcm</span> <a href="#narrow/stream/213817-t-lang/topic/postfix.20macros/near/216031059">said</a>:</p>
<blockquote>
<p>Oh, interesting.  I'm surprised keywords aren't just blanket blocked in macro identifier names.</p>
</blockquote>
<p>I just confirmed that you can name a macro argument <code>$for</code> or <code>$if</code> as well.</p>



<a name="216031471"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/postfix%20macros/near/216031471" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/postfix.20macros.html#216031471">(Nov 08 2020 at 23:35)</a>:</h4>
<p>That's surprising and confusing...</p>



<a name="216031550"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/postfix%20macros/near/216031550" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/postfix.20macros.html#216031550">(Nov 08 2020 at 23:37)</a>:</h4>
<p>I <em>also</em> just confirmed that you can use <code>$r#if</code> as a macro argument name, which suggests a path to fixing this...</p>



<a name="216031552"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/postfix%20macros/near/216031552" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/postfix.20macros.html#216031552">(Nov 08 2020 at 23:37)</a>:</h4>
<p>I wonder how much it would break if, in an edition, we prohibited the use of keywords as macro argument names?</p>



<a name="216031623"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/postfix%20macros/near/216031623" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/postfix.20macros.html#216031623">(Nov 08 2020 at 23:38)</a>:</h4>
<p><span class="user-mention" data-user-id="125270">@scottmcm</span> What are the chances I could talk you into writing (or collaborating on) an extremely simple lang MCP to that effect?</p>



<a name="216031710"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/postfix%20macros/near/216031710" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/postfix.20macros.html#216031710">(Nov 08 2020 at 23:41)</a>:</h4>
<p>I think it would suffice to make it clear that we observed this by way of proposals like RFC 2968 and RFC 2442, but in general we would like room to expand macro syntax as well as avoid confusion.</p>



<a name="216031784"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/postfix%20macros/near/216031784" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/postfix.20macros.html#216031784">(Nov 08 2020 at 23:43)</a>:</h4>
<p>Whether it's adding <code>$super</code>, or adding some kind of syntax-level iteration or conditionals (e.g. <code>$for token in $some_tt</code> or <code>$if something about a parameter</code>), or any number of other potential future proposals, I think it'd be a good idea.</p>



<a name="216031930"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/postfix%20macros/near/216031930" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/postfix.20macros.html#216031930">(Nov 08 2020 at 23:46)</a>:</h4>
<p>I'd be happy to help write and support that proposal, I'd just like to have some additional support pitching it.</p>



<a name="216032455"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/postfix%20macros/near/216032455" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/postfix.20macros.html#216032455">(Nov 09 2020 at 00:00)</a>:</h4>
<p><a href="https://github.com/rust-lang/lang-team/issues/68">https://github.com/rust-lang/lang-team/issues/68</a></p>



<a name="216032475"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/postfix%20macros/near/216032475" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/postfix.20macros.html#216032475">(Nov 09 2020 at 00:01)</a>:</h4>
<p><span class="user-mention silent" data-user-id="239881">Josh Triplett</span> <a href="#narrow/stream/213817-t-lang/topic/postfix.20macros/near/216031552">said</a>:</p>
<blockquote>
<p>I wonder how much it would break if, in an edition, we prohibited the use of keywords as macro argument names?</p>
</blockquote>
<p>I know I have used <code>$self</code> as a macro arg in the past/present</p>



<a name="216041500"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/postfix%20macros/near/216041500" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/postfix.20macros.html#216041500">(Nov 09 2020 at 03:46)</a>:</h4>
<p><span class="user-mention" data-user-id="271719">@Mario Carneiro</span> Would it be much of an imposition to need to change that in an edition, if there's a rustfix?</p>



<a name="216041525"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/postfix%20macros/near/216041525" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/postfix.20macros.html#216041525">(Nov 09 2020 at 03:47)</a>:</h4>
<p>well I could do it certainly, but it's also nice to be able to do</p>



<a name="216041581"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/postfix%20macros/near/216041581" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/postfix.20macros.html#216041581">(Nov 09 2020 at 03:48)</a>:</h4>
<p>specifically, I use it to pass in the <code>self</code> argument from a function when dealing with hygiene</p>



<a name="216041595"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/postfix%20macros/near/216041595" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> isHavvy <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/postfix.20macros.html#216041595">(Nov 09 2020 at 03:48)</a>:</h4>
<p><code>$celf</code></p>



<a name="216041616"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/postfix%20macros/near/216041616" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/postfix.20macros.html#216041616">(Nov 09 2020 at 03:49)</a>:</h4>
<p>there is always the tried and true <code>this</code> for "not-<code>self</code>"</p>



<a name="216041682"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/postfix%20macros/near/216041682" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/postfix.20macros.html#216041682">(Nov 09 2020 at 03:50)</a>:</h4>
<p>And of course there's always <code>$r#self</code>, which I've tested and confirmed to work.</p>



<a name="216043050"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/postfix%20macros/near/216043050" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/postfix.20macros.html#216043050">(Nov 09 2020 at 04:27)</a>:</h4>
<p><span class="user-mention silent" data-user-id="271719">Mario Carneiro</span> <a href="#narrow/stream/213817-t-lang/topic/postfix.20macros/near/216032475">said</a>:</p>
<blockquote>
<p><span class="user-mention silent" data-user-id="239881">Josh Triplett</span> <a href="#narrow/stream/213817-t-lang/topic/postfix.20macros/near/216031552">said</a>:</p>
<blockquote>
<p>I wonder how much it would break if, in an edition, we prohibited the use of keywords as macro argument names?</p>
</blockquote>
<p>I know I have used <code>$self</code> as a macro arg in the past/present</p>
</blockquote>
<p>I have also used that</p>



<a name="216043053"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/postfix%20macros/near/216043053" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/postfix.20macros.html#216043053">(Nov 09 2020 at 04:27)</a>:</h4>
<p>it would be nice not to have to change it, I use it pretty frequently</p>



<a name="216043056"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/postfix%20macros/near/216043056" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/postfix.20macros.html#216043056">(Nov 09 2020 at 04:27)</a>:</h4>
<p>I would probably change to <code>$this</code> instead which seems less clear</p>



<a name="216043104"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/postfix%20macros/near/216043104" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/postfix.20macros.html#216043104">(Nov 09 2020 at 04:28)</a>:</h4>
<p>(side note - it really annoys me that I have to use <code>|this| this.x()</code> when in a function taking self - why can't I just shadow <code>self</code>?)</p>



<a name="216055571"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/postfix%20macros/near/216055571" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/postfix.20macros.html#216055571">(Nov 09 2020 at 08:42)</a>:</h4>
<p>Relatedly, I wish <code>self</code> were less "special" among variable names. Couldn't it just be a contextual keyword in the first argument position of a function declaration?</p>



<a name="216122863"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/postfix%20macros/near/216122863" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Daniel Henry-Mantilla <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/postfix.20macros.html#216122863">(Nov 09 2020 at 18:12)</a>:</h4>
<p><span class="user-mention silent" data-user-id="239881">Josh Triplett</span> <a href="#narrow/stream/213817-t-lang/topic/postfix.20macros/near/216031366">said</a>:</p>
<blockquote>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="n">macro_rules</span><span class="o">!</span><span class="w"> </span><span class="n">postfix</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="cp">$self</span><span class="p">.(</span><span class="cp">$arg1</span>:<span class="nc">tt</span><span class="p">,</span><span class="w"> </span><span class="cp">$arg2</span>:<span class="nc">expr</span><span class="p">)</span><span class="w"> </span><span class="o">=&gt;</span><span class="w"> </span><span class="o">..</span><span class="p">.</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>
</blockquote>
<p>This indeed looks like a very nice syntax. If we were to support that, then the question of how the "receiver" is named becomes a non-issue, since the syntax makes it obvious that we are talking of a receiver type. This way, there is no need to special-case a <em>name</em>. At worst, if there was no such syntax, then the <code>:self</code> capture type would already allow to disambiguate, so that people could call that receiver <code>$self</code>, but they could also call it <code>$result:self, …</code>, for instance, if dealing with <code>.unwrap_or!</code><br>
TL,DR: Magic names are handy when there are no other disambiguators, but in this case, it turns out there is one!</p>



<a name="216123213"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/postfix%20macros/near/216123213" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/postfix.20macros.html#216123213">(Nov 09 2020 at 18:14)</a>:</h4>
<p><span aria-label="+1" class="emoji emoji-1f44d" role="img" title="+1">:+1:</span></p>



<a name="216123231"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/postfix%20macros/near/216123231" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/postfix.20macros.html#216123231">(Nov 09 2020 at 18:15)</a>:</h4>
<p>Yeah, rewriting to just remove the special name seems easiest.</p>



<a name="216128398"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/postfix%20macros/near/216128398" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/postfix.20macros.html#216128398">(Nov 09 2020 at 18:56)</a>:</h4>
<p>would it be a horribly bad idea to just allow all macros where the first item is an $expr to be used in either postfix or prefix notation?</p>



<a name="216128470"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/postfix%20macros/near/216128470" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/postfix.20macros.html#216128470">(Nov 09 2020 at 18:56)</a>:</h4>
<p>I wouldn't say "horrible", but I think there's value in opting in.</p>



<a name="216128514"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/postfix%20macros/near/216128514" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/postfix.20macros.html#216128514">(Nov 09 2020 at 18:57)</a>:</h4>
<p>I don't think this is just a matter of style.</p>



<a name="216128551"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/postfix%20macros/near/216128551" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/postfix.20macros.html#216128551">(Nov 09 2020 at 18:57)</a>:</h4>
<p>If you have a macro whose semantics makes sense to use postfix, you can trivially add a case for postfix.</p>



<a name="216128622"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/postfix%20macros/near/216128622" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/postfix.20macros.html#216128622">(Nov 09 2020 at 18:58)</a>:</h4>
<p>And if you want to adapt someone else's macro, you can easily write a wrapper macro that allows postfix.</p>



<a name="216131110"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/postfix%20macros/near/216131110" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/postfix.20macros.html#216131110">(Nov 09 2020 at 19:18)</a>:</h4>
<p>If the receiver is only evaluated once (which makes sense), I think this should require explicit opt-in from macros</p>



<a name="216131190"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/postfix%20macros/near/216131190" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/postfix.20macros.html#216131190">(Nov 09 2020 at 19:19)</a>:</h4>
<p>A macro might intentionally repeat a particular <code>expr</code> to evaluate  it multiple times, and I think changing that depending on how the macro si invoked could be very confusing</p>



<a name="216131347"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/postfix%20macros/near/216131347" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/postfix.20macros.html#216131347">(Nov 09 2020 at 19:20)</a>:</h4>
<p>I think allowing all macros to be automatically used postfix opens up a bunch of questions that I'd rather avoid, like whether you can do <code>struct Foo {}.bar!()</code>.  Forcing it to only work with the special form (whether that's syntax or a <code>self</code> matcher) so it's clearly the "this can only take a value" makes sense to me.  (Assuming that the overall "postfix macros are valuable and only take values not <code>tt</code>s" is desirable.)</p>



<a name="216149557"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/postfix%20macros/near/216149557" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/postfix.20macros.html#216149557">(Nov 09 2020 at 22:11)</a>:</h4>
<p>I also think that postfix macros should receive their arguments unevaluated. Yes it's confusing for <code>foo.bar().baz!()</code> to have <code>baz!</code> possibly change the meaning of the preceding code, but that's just a macro "best practices" question, it should not be decided at the compiler level</p>



<a name="216150243"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/postfix%20macros/near/216150243" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/postfix.20macros.html#216150243">(Nov 09 2020 at 22:19)</a>:</h4>
<p>We should <em>encourage</em> macro authors to evaluate their <code>$self</code> arguments, but it seems entirely out of place for this to be a language restriction, and it doesn't always even make sense; for some things like <code>typed!</code> you might want to alter the way in which the preceding code is type inferred, and you might also change scoping. More general expression manipulation seems more dubious to me (as in, you would be making spaghetti code if you used this), but I find the argument for consistency with other kinds of macros compelling.</p>



<a name="216154589"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/postfix%20macros/near/216154589" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/postfix.20macros.html#216154589">(Nov 09 2020 at 23:08)</a>:</h4>
<p>Knowing how far back to go is the hard part there, to me.  It feels weird that it could go arbitrarily far backwards -- rust generally has a token at the beginning to warn the reader that the interpretation of this region is different, like <code>async</code> or even <code>loop</code>.</p>



<a name="216161874"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/postfix%20macros/near/216161874" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/postfix.20macros.html#216161874">(Nov 10 2020 at 00:55)</a>:</h4>
<p>I think that any code where this becomes a serious concern is already abusing macros</p>



<a name="216312583"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/postfix%20macros/near/216312583" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> est31 <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/postfix.20macros.html#216312583">(Nov 11 2020 at 06:45)</a>:</h4>
<p>Personally I'm a fan of UFCS syntax (what <span class="user-mention" data-user-id="220273">@Jane Lusby</span>  suggested). <code>struct Foo {}.bar!()</code> would be weird indeed, but this case can be avoided in the parser to only allow postfix macros if the code in front of the . is an expression. This is already done by my PR to add parsing support for postfix macros.</p>



<a name="216357921"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/postfix%20macros/near/216357921" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/postfix.20macros.html#216357921">(Nov 11 2020 at 15:13)</a>:</h4>
<p>The specific reason I defined the evaluation as part of the language was specifically to avoid the reinterpretation confusion. Postfix macros are a hard enough sell without the added complication of reinterpreting tokens that aren't wrapped inside a macro.</p>



<a name="216411937"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/postfix%20macros/near/216411937" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> est31 <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/postfix.20macros.html#216411937">(Nov 11 2020 at 23:51)</a>:</h4>
<p>What do you mean by reinterpretation confusion? That people are confused that macros may evaluate the expression multiple times?</p>



<a name="216412910"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/postfix%20macros/near/216412910" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/postfix.20macros.html#216412910">(Nov 12 2020 at 00:06)</a>:</h4>
<p>No, that people may be confused that control of the evaluation of those tokens is up to the macro. It can evaluate the expression zero, 1, or N times, or it can reinterpret the tokens in an entirely different way. That's a desirable property for normal macros, and in an expression like <code>mac!(tokens here)</code> you <em>expect</em> the macro to control the interpretation of the tokens. But in <code>a().b().mac!(tokens here)</code>, while it's obvious that the macro controls the interpretation of <code>tokens here</code>, I don't think the macro should control the interpretation of <code>a().b()</code>.</p>



<a name="216488681"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/postfix%20macros/near/216488681" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Daniel Henry-Mantilla <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/postfix.20macros.html#216488681">(Nov 12 2020 at 16:05)</a>:</h4>
<p>In other words, <code>&lt;expr…&gt;.mac!(…)</code> would  have an unsugaring with the semantics of:</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="k">match</span><span class="w"> </span><span class="o">&lt;</span><span class="n">expr</span><span class="err">…</span><span class="o">&gt;</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="n">receiver_expr</span><span class="w"> </span><span class="o">=&gt;</span><span class="w"> </span><span class="n">mac</span><span class="o">!</span><span class="p">(</span><span class="n">receiver_expr</span><span class="p">,</span><span class="w"> </span><span class="err">…</span><span class="p">)</span><span class="w"> </span><span class="p">}</span><span class="w"></span>
</code></pre></div>
<p>thus giving the macro receiver input semantics similar to those of a normal function, while keeping the ability, contrary to a function / closure / method, of emitting control-flow altering statements, which I think is indeed the main use-case / wanted feature of postfix macros. I personally find that suggestion quite elegant <span aria-label="smile" class="emoji emoji-1f642" role="img" title="smile">:smile:</span></p>
<ul>
<li>The main drawback of using <em>exactly that implementation for the unsugaring</em> being that it would not be possible to stringify the input (so no <code>.stringify!()</code> or <code>.dbg!()</code>). That's a bit of a bummer (mainly the last one), so I wonder if <code>receiver_expr</code> could use a special fake identifier that gets stringified as <code>&lt;expr…&gt;</code> <span aria-label="thinking" class="emoji emoji-1f914" role="img" title="thinking">:thinking:</span></li>
</ul>



<a name="216490664"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/postfix%20macros/near/216490664" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/postfix.20macros.html#216490664">(Nov 12 2020 at 16:17)</a>:</h4>
<p><span class="user-mention" data-user-id="232018">@Daniel Henry-Mantilla</span> Is there an advantage of a <code>match</code> over a <code>let</code> for the desugaring? (I'd written the <code>let</code> desugaring in the RFC, but I'm not attached to that.)</p>



<a name="216490786"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/postfix%20macros/near/216490786" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/postfix.20macros.html#216490786">(Nov 12 2020 at 16:18)</a>:</h4>
<p>And that's true, we <em>could</em> stringify it to be the preceding expression as a string, without allowing reinterpretation of the tokens.</p>



<a name="216490883"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/postfix%20macros/near/216490883" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> kennytm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/postfix.20macros.html#216490883">(Nov 12 2020 at 16:19)</a>:</h4>
<p>there is <a href="https://internals.rust-lang.org/t/idea-postfix-let-as-basis-for-postfix-macros/12438">https://internals.rust-lang.org/t/idea-postfix-let-as-basis-for-postfix-macros/12438</a> if you need the macro not able to touch the <code>a().b()</code> part at all (ignore the "postfix let" part, focus on the macro)</p>



<a name="216496933"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/postfix%20macros/near/216496933" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Daniel Henry-Mantilla <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/postfix.20macros.html#216496933">(Nov 12 2020 at 17:00)</a>:</h4>
<p><span class="user-mention silent" data-user-id="239881">Josh Triplett</span> <a href="#narrow/stream/213817-t-lang/topic/postfix.20macros/near/216490664">said</a>:</p>
<blockquote>
<p><span class="user-mention silent" data-user-id="232018">Daniel Henry-Mantilla</span> Is there an advantage of a <code>match</code> over a <code>let</code> for the desugaring? (I'd written the <code>let</code> desugaring in the RFC, but I'm not attached to that.)</p>
</blockquote>
<p>temporaries that <code>receiver_expr</code> may refer to are guaranteed to live until the end of the <code>match</code> block, thus preventing <code>receiver_expr</code> from being unusable: <a href="https://play.rust-lang.org/?version=stable&amp;mode=debug&amp;edition=2018&amp;gist=2e0516aa14e5d15c20994709b1b74010">see the following error with <code>let</code></a></p>
<ul>
<li>(basically Rust does not have <code>let … in</code>, except when using <code>match</code>)</li>
</ul>



<a name="216509299"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/postfix%20macros/near/216509299" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/postfix.20macros.html#216509299">(Nov 12 2020 at 18:35)</a>:</h4>
<p><span class="user-mention" data-user-id="232018">@Daniel Henry-Mantilla</span> Interesting, thank you. I'll update the desugaring then.</p>



<a name="216650678"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/postfix%20macros/near/216650678" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/postfix.20macros.html#216650678">(Nov 13 2020 at 18:16)</a>:</h4>
<p>I'm of two minds about postfix macros. I do think that I'd like -- someday -- to be able to add type-directed macros (e.g., macros in impl blocks). I also think it'd be a huge refactoring and we could get "lexical method macros" <em>much</em> faster, and I kind of think that one path precludes the other. I haven't read the RFC <span class="user-mention" data-user-id="239881">@Josh Triplett</span>, but do you feel like there is a transition path down the line?</p>



<a name="216650721"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/postfix%20macros/near/216650721" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/postfix.20macros.html#216650721">(Nov 13 2020 at 18:17)</a>:</h4>
<p>I am wondering if there is some way to setup a simple version of type-directed macros that wouldn't be as much of an impl challenge</p>



<a name="216650766"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/postfix%20macros/near/216650766" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/postfix.20macros.html#216650766">(Nov 13 2020 at 18:17)</a>:</h4>
<p>I really don't think that one path precludes the other.</p>



<a name="216650822"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/postfix%20macros/near/216650822" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/postfix.20macros.html#216650822">(Nov 13 2020 at 18:17)</a>:</h4>
<p>Hmm, I feel like it'd be a lot of complexity to support <em>both</em></p>



<a name="216650877"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/postfix%20macros/near/216650877" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/postfix.20macros.html#216650877">(Nov 13 2020 at 18:18)</a>:</h4>
<p>I think we can have "global" postfix macros, and also (if we want and they're feasible) type-directed postfix macros.</p>



<a name="216650892"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/postfix%20macros/near/216650892" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/postfix.20macros.html#216650892">(Nov 13 2020 at 18:18)</a>:</h4>
<p>The former would effectively be a blanket impl.</p>



<a name="216651036"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/postfix%20macros/near/216651036" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/postfix.20macros.html#216651036">(Nov 13 2020 at 18:19)</a>:</h4>
<p>If we <em>want</em> a transition in the future, I think it would look like blanket impls containing the non-type-directed macros.</p>



<a name="216651074"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/postfix%20macros/near/216651074" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/postfix.20macros.html#216651074">(Nov 13 2020 at 18:20)</a>:</h4>
<p>But I don't think we want or need that transition.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>